Skip to content

bpo-46475: Add typing.Never and typing.assert_never#30842

Merged
gvanrossum merged 13 commits into
python:mainfrom
JelleZijlstra:never
Feb 8, 2022
Merged

bpo-46475: Add typing.Never and typing.assert_never#30842
gvanrossum merged 13 commits into
python:mainfrom
JelleZijlstra:never

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Jan 23, 2022

Copy link
Copy Markdown
Member

Another pending proposal from typing-sig.

  • Add a Never primitive that is semantically identical to NoReturn, but documented explicitly as a bottom type. I chose to make it a separate object instead of a pure alias for NoReturn so that dynamic checkers can distinguish between the two and so that we can document them separately.
  • Add an assert_never() function to statically assert that code is unreachable. Based on @davidfstr's feedback, the error raised by the function does not include the argument.

https://bugs.python.org/issue46475

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants